
Page({
  data:{
    isShow:true,
    price:3000,
    arr:"",
    rating:9,
    movies:""
  },
  onLoad(){
    wx.request({
      url: 'http://192.168.4.18:8000/',
      data: {},
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result)=>{
        var movies = result.data.result
        this.setData({
          movies
        })
      }
    });
    // var data = this.data.rating
    // var res = this.transformStart(data)
    // this.setData({
    //   arr:res
    // })
  },
  transformStart(num){
    let arr = []
    for(let i=0;i<5;i++){
      if(num>2){
        arr.push(2)
      }else if(num>0){
        arr.push(num)
      }else{
        arr.push(0)
      }
      num=num-2;
    }
    return arr;
  }
})
